//
//  GenerateUserId.swift
//  loveHHEveryDay
//
//  Created by yw on 2025/4/9.
//

import Foundation


func generateDistributedUniqueID() -> String {
    let timestamp = Int(Date().timeIntervalSince1970)
    let randomNumber = Int.random(in: 0..<10000)
    let combinedValue = "\(timestamp)\(randomNumber)"
    let hashValue = String(combinedValue.hashValue)
    let uniqueID = String(hashValue.prefix(12))
    return uniqueID
}


func generateUniqueID(length: Int) -> String {
    let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    var result = ""
    for _ in 0..<length {
        let randomIndex = Int.random(in: 0..<characters.count)
        let index = characters.index(characters.startIndex, offsetBy: randomIndex)
        result.append(characters[index])
    }
    return result
}


